namespace Geekeradmin.Middleware
{
    /// <summary>
    /// 404中间件
    /// </summary>
    public class Jump404Middleware
    {
        private readonly RequestDelegate next;

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="next"></param>
        public Jump404Middleware(RequestDelegate next)
        {
            this.next = next;
        }

        /// <summary>
        /// 执行方法
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task Invoke(HttpContext context)
        {
            if (!context.Response.HasStarted)
            {
                await this.next.Invoke(context);
            }

            if (context.Response.StatusCode == 404)
            {
                //context.Response.Redirect("/api/Menu/NoPage");
            }
        }
    }
}
